
 <template>
 	<el-dialog title="" visible :show-close="false" :modal-append-to-body="false" class="wrap" >
 		<i class="el-icon-close close" @click="cancel" style="color: white;z-index: 99;"></i>
		 <div class="bt">人事信息修改</div>
 		<el-form label-width="100px" class="form">
 			<el-form-item label="中文名">
 				<el-input v-model="form.zwm"  placeholder="请输入" class="select-block"></el-input>
 			</el-form-item>
 			<el-form-item label="英文名">
 				<el-input v-model="form.ywm"  placeholder="请输入" class="select-block"></el-input>
 			</el-form-item>
 			<el-form-item label="电话">
 				<input v-model="form.dh" type="number" @blur='yz'   class="input1" style="width: 85%;float: left;text-align: left;">
 				<!--<el-input v-model="form.dh"  placeholder="请输入" class="select-block"></el-input>-->
 			</el-form-item>
 			<el-form-item label="身份证">
 				<el-input v-model="form.sfz" @blur='sfyz'  placeholder="请输入身份证" class="select-block"></el-input>
 		    </el-form-item>
 		    <el-form-item label="性别">
                   <el-select v-model="form.xb"   class="select-block">
  					  <el-option label="男" value="男"></el-option>
  					  <el-option label="女" value="女" ></el-option>
  			      </el-select>
 			</el-form-item>
 			<el-form-item label="职位">
  			      <el-select v-model="form.lscode" class="select-block"  >
					<el-option :label="v.mc" :value="v.code" v-for="v in comboxlist"></el-option>
		    </el-select>
 			</el-form-item>
      <el-form-item label="在职状态">
        <el-tooltip  placement="top" class="sx" style="float: left; vertical-align: auto; margin-top:8px; " >
  				<el-switch  v-model="form.isqy"  active-color="#13ce66" inactive-color="#ff4949"  inactive-text="离职" active-text="在职" active-value="Y" inactive-value="N"></el-switch>
  			</el-tooltip>
 			</el-form-item>
 		</el-form>
 		<el-button type="primary" class="submit" @click="submit">修改</el-button>
 		<el-button type="danger" class="submit" @click="cancel">退出</el-button>
 	</el-dialog>
 </template>
 <script type="text/javascript">
 	import qs from 'qs'
 	export default {
 		props: ['params'],
 		data() {
 			return {
 				form: {
//					gh :'',
//					mm :'',
					dh :'',
					tx :'',
					xb :'',
					sfz:'',
					zwm :'',
					ywm :'',
					isqy:'',
					lscode:'',
 					id:'',
//        xzls:'',
 				},
        xzlsList: [],
        comboxlist:[],
        sx:'Y'
 			}
 		},
 		created() {
  		 this.form.id = this.params.row.id;
          this.loadinfo();
          this.getcomlist();
//        this.getxzlsList();
 		},
 		methods: {
 			yz(){
				if(!(/^1\d{10}$/.test(this.form.dh))){
						this.$message.error('输入手机号不正确！');
					}
			},
			sfyz(){
				if(!(/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(this.vsfz))){
						this.$message.error('输入身份证号不正确！');
					}
			},
 			getcomlist(){
				var logininfo = JSON.parse(localStorage.logininfo) ;
				var params3 = qs.stringify({
					yhid:logininfo.id,
					xxid:logininfo.xxid,
				});
					this.searchLoading = true;
					this.axios.post(this.$store.state.api + 'lstype/getlstypexlk',params3)
					.then( res => {
							let data = res.data.data;
							let list = data.list;
							this.comboxlist=list;
					}).catch( res => {
							this.searchLoading = false;
					})
			},
 			loadinfo(){
 				var logininfo = JSON.parse(localStorage.logininfo);
                var params2 = qs.stringify({
                  xxid:logininfo.xxid,
 							 yhid:logininfo.id,
 							 id:this.form.id
                })
                //执行
                this.axios.post(this.$store.state.api + 'ls/info',  params2 )
                .then(res => {
 							this.form=res.data.data;
 							if(!this.form.dh){
 								this.form.dh=''
 							}
 							if(!this.form.xb){
 								this.form.xb='男'
 							}
                 }).catch(res => {
					this.$message.danger("服务器异常");
 			 				this.$emit('close', { type: 'info', cancel: true });
				})
 			},
 			 submit() {
 				//检测
 				this.$store.state.loading = true;
 				var logininfo = JSON.parse(localStorage.logininfo);
 				var params2 = qs.stringify({
                        isqy:this.form.isqy,
 						zwm: this.form.zwm,
 						ywm: this.form.ywm,
 						sfz: this.form.sfz,
			            xb: this.form.xb,
			            dh: this.form.dh,
			            id: this.form.id,
			            lstype:this.form.lscode,
 						yhid: logininfo.id,
 						xxid: logininfo.xxid
 					})
 				//执行
 				    this.axios.post(this.$store.state.api + 'ls/update',  params2 )
 						.then(res => {
 							if(res.data.code == 1) {
 								this.$emit('close', { type: 'edit', cancel: false });
 								this.$message.success(res.data.msg);
 								this.$store.state.loading = false;
 							} else {
 								this.$message.warning(res.data.msg);
 							}
 						}).catch(res => {
 							 this.$message.danger("服务器异常");
 							this.$store.state.loading = false;
 						})
 			},
 			cancel() {
 				this.$emit('close', { type: 'edit', cancel: true })
 			}
 		}
 	}
 </script>
 <style lang="less" scoped>
 	.wrap {
 		text-align: center;
 	}
 	.bt{
			position: absolute;
			width: 100%;
			height: 50px;
			margin: 0 auto;
			top:0;
			left:0;
			background: #50BFFF;
			margin-bottom: 20px;
			color:white;
			text-align:left;
			line-height: 50px;
			font-size: 17px;
			padding-left: 15px;
		}
 	.form {
 		text-align: center;
 		margin-top: 20px;
 		padding-right: 20px;
 	}
 	.input {
             display: inline-block;
         }
 	.select-block {
 		display: block;
 		width: 85%;
 	}
 	.submit {
 		width: 120px;
 	}
 	.input1{
		    width: 300px;
			height: 30px;
			text-align: left;
			/*outline: none;*/
			border: 1px solid #CCCCCC;
			background: none;
			border-radius: 5px;
			// margin-left: 20%;
			text-align: center;
	}
	input::-webkit-outer-spin-button,
	input::-webkit-inner-spin-button{
   -webkit-appearance: none !important;
    }
    input[type="number"]{-moz-appearance:textfield;}
 </style>
